package mobi.hami.huapin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import mobi.hami.huapin.base.Result;
import mobi.hami.huapin.constants.BaseEnums;
import mobi.hami.huapin.service.HpShareLogService;
import mobi.hami.huapin.service.PrintLogService;
import mobi.hami.huapin.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 打印相关
 *
 * @author 阿飞 jijunjian@hami.mobi
 * @date 10/8/2018 8:25 PM
 */

@RequestMapping(value = "/print",produces = "application/json")
@Api(description = "打印相关记录")
@RestController
public class PrintLogController {

    @Autowired
    private PrintLogService printLogService;

    @RequestMapping(value = "/save.do", method = RequestMethod.POST)
    @ApiOperation(value = "保存打印记录", notes = "{\n" +
            "  \"hp_id\": \"花拼id\",\n" +
            "  \"admin\": \"管理员\"\n" +
            "}")
    public Result share(@RequestBody Map<String, String> reqMap) {

        int rs = printLogService.save(reqMap);

        return Results.successWithData(rs, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }

    @RequestMapping(value = "/printcount.do", method = RequestMethod.POST)
    @ApiOperation(value = "打印次数查询", notes = "根据花拼id返回打印次数 ")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "hp_id", value = "花拼id", example = "21", paramType = "query", required = true, dataType = "Integer"),
            }
    )
    public Result queryPrintCount(Long hp_id) {

        int rs = printLogService.queryPrintCount(hp_id);

        return Results.successWithData(rs, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }
}
